package cn.com.HiSting1990.MyBasis;

import java.util.ArrayList;
import java.util.StringJoiner;

public class MyStringJoiner {
    public static void main(String[] args) {

        myStringIntern();

    }

    private static void myBuilder(){
        StringBuilder builder = new StringBuilder();
        long startDate = System.currentTimeMillis();
        for (int i=0;i<10000;i++){
            builder.append("B"+i);
        }
        long endDate = System.currentTimeMillis();
        System.out.println(endDate-startDate);
    }

    private static void myJoiner(){
        StringJoiner joiner = new StringJoiner(",");
        Long startDate = System.currentTimeMillis();
        for (int i=0;i<10000;i++){
            joiner.add("A"+i);
        }
        long endDate = System.currentTimeMillis();
        System.out.println(endDate-startDate);
    }

    private static void myString(){
        ArrayList<String> strs = new ArrayList<>();
        for (int i=0; i<10;i++){
            strs.add(i+"-");
        }
        String ad = String.join(",",strs);
        System.out.println(ad);
    }
    private static void myStringIntern(){
        String a = "Hello";
        String b = new StringBuilder("He").append("llo").toString();
        String c = b.intern();
        System.out.println("a=b  "+(a==b));
        System.out.println("a=c  "+(a==c));

    }
}
